#include <iostream>
#include <stack>
#include <queue>


int main()
{
    std::stack<int> s;
    std::queue<int> q;
    
    for(int i = 0;i < 31;i++)
    {
        q.push(i+1);
    }

    int count = 0;
    while(q.size() > 1)
    {
        int temp = q.front();
        q.pop();
        count++;
        if(count == 3)
        {
            std::cout<<temp<<"出局!\n";
            count = 0;
        }
        else
        {
            q.push(temp);
        }
    }
    std::cout<<q.front()<<"活了下来"<<std::endl;
    return 0;
}